<template>
    <Table :columns="columns1" :data="data"  :loading="tableload" ></Table>  

</template>
<script>
export default {
    props:['infoId'],
    data () {
        return {
            editUrl:'api/teacher/v1/headteacher/teacher_records?id=',//请求单条数据路径
            columns1:[
                {
                    title: '学年',
                    align: 'center',
                    width:120,
                    render: (h, params) => {
                        if(params.row.schoolyear!==null){
                            let name = params.row.schoolyear.schoolyear_name.zh                           
                            return h('div', name);
                        }
                    }
                },
                {
                    title: '学期',
                    align: 'center',
                    width:130,
                    render: (h, params) => {
                        if(params.row.semester!==null){
                            let name = params.row.semester.semester_name.zh                          
                            return h('div', name);
                        }
                    }
                },
                {
                    title: '班主任',
                    align: 'center',
                    render: (h, params) => {
                        return h('div', params.row.eclass_name.zh?params.row.eclass_name.zh:params.row.eclass_name.mn);
                    },
                    width:120,
                    render: (h, params) => {
                        if(params.row.teacher!==null){
                            let name = params.row.teacher.teacher_name.zh                          
                            return h('div', name);
                        }
                    }
                },
                {
                    title: '异动时间',
                    align: 'center',
                    key: 'start_at',
                    width:200,
                },
                {
                    title: '异动状态',
                    align: 'center',
                    // key: 'trans',
                    width:120,
                    render: (h, params) => {
                        if(params.row.trans!==null){
                            let name = params.row.trans.dictionary_name.zh                            
                            return h('div', name);
                        }
                    }
                },
                {
                    title: '异动原因',
                    align: 'center',
                    render: (h, params) => {
                        if(params.row.reason !=null){
                            let name = params.row.reason.zh                            
                            return h('div', name);
                        }
                    },
                    width:120,
                },
                {
                    title: ' ',
                },
            ],
            data: [],
            tableload:true
        }
    },
    methods: {
        
        /************************************************************
         * 
         * 单条数据请求
         * 
         ************************************************************/
        infodata(){
            this.$http.get(this.editUrl+this.infoId)
            .then(val=>{   
                this.data = JSON.parse(JSON.stringify(val.data))
                this.tableload=false      
            })
            .catch(err=>{
                if(err.code && err.code==422) {
                    this.$Message.error(err.message);
                }
                this.tableload=false  
            })
        },
        

    },
    mounted(){
        this.infodata()
    },

}
</script>
<style lang="less">
.ivu-table{
    height:auto;
}
</style>
